script_enemy_main{

let speed1=1;
let randomangle1=0;
let speed2=1;
let randomangle2=0;

let angle3a=rand(0,360);
let angle3b=0;
let speed3=2;
let angle4a=rand(0,360);
let angle4b=0;
let speed4=2;

let character="TomomiTakeo";
let cutin=character;
let dispelled=0;
let spellcards=2;
let spellcardnumber=32;
let damagerate=10;
let usespell=0;
let bgfade=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotm6=("script\SoundEffects\shotm6.wav");

let BG1=("\script\Images\BackgroundLayers\Tomomi3.png");
let BG2=("\script\Images\BackgroundLayers\Takeo1b.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsTomomiTakeo1.txt");

	LoadSE("script\SoundEffects\shotm6.wav");
	
	LoadGraphic("\script\Images\BackgroundLayers\Tomomi3.png");
	LoadGraphic("\script\Images\BackgroundLayers\Takeo1b.png");

	LoadGraphic("\script\Images\CharacterSprites\Tomomi.png");
	LoadGraphic("\script\Images\CharacterSprites\Takeo.png");

	SetScore(300000);
	SetLife(300);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);

	SetCommonData("UseSpell1",0);
	SetCommonData("UseSpell2",0);

	SetX(cx);
	SetY(miny-500);
}
	
@MainLoop{

SetCollisionA(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionA(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetCollisionB(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionB(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Faux Pas [Splashing The Pot] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time==0){
CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Tomomi.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Takeo.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
}


let TomomiX=GetCommonData("Boss1X");
let TomomiY=GetCommonData("Boss1Y");
let TakeoX=GetCommonData("Boss2X");
let TakeoY=GetCommonData("Boss2Y");

if(frame>=130 && frame<160 && frame%3==0){
SetCommonData("UseSpell1",20);
	let angle=rand(-3-randomangle1,3+randomangle1);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Familiar.txt",TomomiX-20,TomomiY-50,0,0,[speed1,angle,1]);
	speed1-=0.075;
	randomangle1+=3;
}
if(frame>=300 && frame<330 && frame%3==0){
SetCommonData("UseSpell2",20);
	let angle=rand(-3-randomangle2,3+randomangle2);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Familiar.txt",TakeoX-10,TakeoY-30,0,0,[speed2,angle,6]);
	speed2-=0.075;
	randomangle2+=3;
}
if(frame>=330){
	frame=0;
	speed1=1; randomangle1=0;
	speed2=1; randomangle2=0;
	speed3=2; angle3a=rand(0,360); angle3b=0;
	speed4=2; angle4a=rand(0,360); angle4b=0;
}


if(frame>=130 && frame<160 && frame%4==0){
SetCommonData("UseSpell2",-20);
	loop(25){
	CreateShot01(TakeoX,TakeoY-10,speed3,angle3a+angle3b,8,10);
	angle3a+=360/25;
	}
angle3b+=2;
speed3+=0.2;
}
if(frame>=300 && frame<330 && frame%4==0){
SetCommonData("UseSpell1",-20);
	loop(25){
	CreateShot01(TomomiX,TomomiY-10,speed4,angle4a-angle4b,7,10);
	angle4a+=360/25;
	}
angle4b+=2;
speed4+=0.2;
}


if(GetCommonDataDefault("FamiliarDestroyed",0)==1 && OnBomb==false){ AddLife(-10); SetCommonData("FamiliarDestroyed",0); }
if(GetCommonDataDefault("FamiliarDestroyed",0)==1 && OnBomb==true){ SetCommonData("FamiliarDestroyed",0); }

time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }

	SetGraphicRect(0,0,300,300);
	SetGraphicScale(2,2);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(200,200,200);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,-time/4);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0-80*cos(time),0,528-80*cos(time),592);
	SetGraphicScale(1,1);
	SetTexture(BG2);
	SetAlpha(bgfade/2);
	SetColor(255,255,255);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
}

@DrawLoop{
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}